import request from '../../utils/request';

// product-order 管理相关 API

// 发货
export const shipProductOrder = (id, params) => {
    return request({
        url: `/order/product-order/${id}/ship`,
        method: 'put',
        params: params,
    });
};

// 申请退款
export const requestRefund = (id, params) => {
    return request({
        url: `/order/product-order/${id}/refund`,
        method: 'put',
        params: params,
    });
};

// 处理退款
export const processRefund_1 = (id, params) => {
    return request({
        url: `/order/product-order/${id}/process-refund`,
        method: 'put',
        params: params,
    });
};

// 支付订单
export const payProductOrder = (id, params) => {
    return request({
        url: `/order/product-order/${id}/pay`,
        method: 'put',
        params: params,
    });
};

// 确认收货
export const confirmDelivery = (id) => {
    return request({
        url: `/order/product-order/${id}/confirm-delivery`,
        method: 'put',
    });
};

// 取消订单
export const cancelProductOrder = (id, params) => {
    return request({
        url: `/order/product-order/${id}/cancel`,
        method: 'put',
        params: params,
    });
};

// 创建商品订单
export const createProductOrder = (data) => {
    return request({
        url: '/order/product-order',
        method: 'post',
        data: data,
    });
};

// 从购物车创建订单
export const createOrderFromCart = (data) => {
    return request({
        url: '/order/product-order/cart',
        method: 'post',
        data: data,
    });
};

// 查询订单详情
export const getProductOrderById = (id) => {
    return request({
        url: `/order/product-order/${id}`,
        method: 'get',
    });
};

// 查询订单详情列表
export const getOrderDetails = (id) => {
    return request({
        url: `/order/product-order/${id}/details`,
        method: 'get',
    });
};

// 分页查询订单列表
export const getProductOrderPage = (params) => {
    return request({
        url: '/order/product-order/page',
        method: 'get',
        params: params,
    });
};

// 查询会员订单列表
export const getMemberProductOrders = (memberId, params) => {
    return request({
        url: `/order/product-order/member/${memberId}`,
        method: 'get',
        params: params,
    });
};

